package cn.xluobo.business.wechat.miniapp.course.controller;

import cn.xluobo.business.sc.course.domain.req.ReqSearchScCourse;
import cn.xluobo.business.sc.course.service.BusinessScCourseService;
import cn.xluobo.business.sc.student.domain.req.ReqSearchStudentCourseCla;
import cn.xluobo.business.sc.student.domain.resp.RespCourseClaStudent;
import cn.xluobo.business.wechat.miniapp.course.service.WechatMiniCourseService;
import cn.xluobo.core.api.APIResponse;
import cn.xluobo.core.page.RespPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 课程
 * @author ：KingLong
 * @date ：Created in 2020/11/5 17:02
 */
@RestController
@RequestMapping("/api/wechat/miniapp/{appId}/course")
public class WechatMiniCourseController {

    @Autowired
    private WechatMiniCourseService miniCourseService;
    @Autowired
    private BusinessScCourseService scCourseService;

    /**
     * 课程、班级 学生列表
     * @param reqSearchStudentCourseCla
     * @return
     */
    @GetMapping("/searchCourseClaStudent")
    public APIResponse searchCourseClaStudent(ReqSearchStudentCourseCla reqSearchStudentCourseCla){
        RespPage<RespCourseClaStudent> respPage = miniCourseService.searchCourseClaStudent(reqSearchStudentCourseCla);
        return APIResponse.toAPIResponse(respPage);
    }

    /**
     * 课程列表
     * @param reqSearchScCourse
     * @return
     */
    @GetMapping("/searchCourseList")
    public APIResponse searchCourseList(ReqSearchScCourse reqSearchScCourse) {
        return scCourseService.searchList(reqSearchScCourse);
    }

    /**
     * 课程详细信息
     * @param courseId
     * @return
     */
    @GetMapping("/courseDetail/{courseId}")
    public APIResponse courseDetail(@PathVariable("courseId") Long courseId) {
        return scCourseService.detailById(courseId);
    }

}
